<!-- 
    DefineProperty: 定义属性;
    prop 
 -->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        let cat = {
            name: "妮蔻",
            sex: "女孩",
        };

        let dog = {
            name: "Alex",
            sex: "男孩",
        };

        cat.age = 2;
        // ************ 为dog定义属性age ************
        // let num = 'sdad';
        Object.defineProperty(dog,'age',{
            enumerable: true,
            get(){
                console.log('get触发了')
                // return dog.age;
            },
            set(val){
            //    console.log(val);
            console.log('set出发了');
               num = val; 
               // set dog.age = val
            }
        });
        // console.log(cat);
        // console.log(Object.keys(cat))
        console.log(dog);
        console.log(dog.age)
        // console.log(Object.keys(dog))
        

        // ************ 为dog定义属性age ************
    </script>
</body>
</html>